package com.woniuxy.mesboot.service.impl;

import com.woniuxy.mesboot.entity.SysEmp;
import com.woniuxy.mesboot.mapper.SysEmpMapper;
import com.woniuxy.mesboot.service.EmpService;
import com.woniuxy.mesboot.vo.EmpOptionVO;
import com.woniuxy.mesboot.vo.EmpSelectVO;
import com.woniuxy.mesboot.vo.EmpVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
public class EmpServiceImpl implements EmpService {
    @Resource
    private SysEmpMapper empMapper;

    @Override
    public List<EmpOptionVO> selectEmpByLevel() {
        List<EmpSelectVO> vos = empMapper.selectEmpByLevel();
        List<EmpOptionVO> depts = new ArrayList<>();
        for (int i = 0; i < vos.size();i++) {
            for (int j = 0; j < depts.size(); j++) {
                depts.get(j).setValue(vos.get(i).getDeptId().toString());
                depts.get(j).setLabel(vos.get(i).getDeptName());
            }
        }
        return depts;
    }

    @Override
    public EmpVO selectByWorkNo(String workNo) {
        return empMapper.selectByWorkNo(workNo);
    }

    @Override
    public List<EmpVO> selectAll() {
        return empMapper.selectAll();
    }

    @Override
    public int deleteByPrimaryKey(Long id) {
        return empMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(SysEmp record) {
        return empMapper.insert(record);
    }

    @Override
    public int insertSelective(SysEmp record) {
        return empMapper.insertSelective(record);
    }

    @Override
    public SysEmp selectByPrimaryKey(Long id) {
        return empMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(SysEmp record) {
        return empMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(SysEmp record) {
        return empMapper.updateByPrimaryKey(record);
    }
}
